package com.cleaningcloud.cld.controller;

import com.cleaningcloud.cld.domain.CldDegreetitleProblem;
import com.cleaningcloud.cld.service.ICldDegreetitleProblemService;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.web.page.TableDataInfo;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 满意度问题Controller
 *
 * @author cleaningcloud
 * @date 2024-10-27
 */
@RestController
@RequestMapping("/problem")
public class CldDegreetitleProblemController extends BaseController {
    @Autowired
    private ICldDegreetitleProblemService cldDegreetitleProblemService;

    /**
     * 查询满意度问题列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CldDegreetitleProblem cldDegreetitleProblem) {
        startPage();
        List<CldDegreetitleProblem> list = cldDegreetitleProblemService.selectCldDegreetitleProblemList(cldDegreetitleProblem);
        return getDataTable(list);
    }

    /**
     * 导出满意度问题列表
     */
    @Log(title = "满意度问题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldDegreetitleProblem cldDegreetitleProblem) {
        List<CldDegreetitleProblem> list = cldDegreetitleProblemService.selectCldDegreetitleProblemList(cldDegreetitleProblem);
        ExcelUtil<CldDegreetitleProblem> util = new ExcelUtil<CldDegreetitleProblem>(CldDegreetitleProblem.class);
        util.exportExcel(response, list, "满意度问题数据");
    }

    /**
     * 获取满意度问题详细信息
     */
    @GetMapping(value = "/{degreetitleProblemId}")
    public AjaxResult getInfo(@PathVariable("degreetitleProblemId") Long degreetitleProblemId) {
        return success(cldDegreetitleProblemService.selectCldDegreetitleProblemByDegreetitleProblemId(degreetitleProblemId));
    }

    /**
     * 新增满意度问题
     */
    @Log(title = "满意度问题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldDegreetitleProblem cldDegreetitleProblem) {
        return toAjax(cldDegreetitleProblemService.insertCldDegreetitleProblem(cldDegreetitleProblem));
    }

    /**
     * 修改满意度问题
     */
    @Log(title = "满意度问题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldDegreetitleProblem cldDegreetitleProblem) {
        return toAjax(cldDegreetitleProblemService.updateCldDegreetitleProblem(cldDegreetitleProblem));
    }

    /**
     * 删除满意度问题
     */
    @Log(title = "满意度问题", businessType = BusinessType.DELETE)
    @DeleteMapping("/{degreetitleProblemIds}")
    public AjaxResult remove(@PathVariable Long[] degreetitleProblemIds) {
        return toAjax(cldDegreetitleProblemService.deleteCldDegreetitleProblemByDegreetitleProblemIds(degreetitleProblemIds));
    }
}
